﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IWMAG.Scripting.Compiler
{
    public interface IUserInfo
    {
        int? LineNumber { get; }
        int? StartIndex { get; }
        int? Length { get; }
        bool? CanCompleteBuild { get; }
    }


    public class UserInfoBase : IUserInfo
    {
        public string Message { get; set; }
        public bool? CanCompleteBuild { get; set; }
        public UserInfoBase(bool canComplete = false, string msg = null, int? lineNumber = null, int? startIndex = null, int? length = null)
        {
            CanCompleteBuild = canComplete;
            this.Message = msg;
            this.LineNumber = lineNumber;
            this.StartIndex = startIndex;
            this.Length = length;
        }
        public int? LineNumber { get; set; }
        public int? StartIndex { get; set; }
        public int? Length { get; set; }

        public override string ToString()
        {
            return Message == null ? base.ToString() : Message.ToString();
        }
    }

    public class CompileError : UserInfoBase
    {
        [Obsolete("Use CompileError2 class instead of this one.", false)]
        public CompileError(string msg = null, int? lineNumber = null, int? startIndex = null, int? length = null) : base(false, msg, lineNumber, startIndex, length) { }
    }

    public class CompileWarning : UserInfoBase
    {
        [Obsolete("Use CompileWarning2 class instead of this one.", false)]
        public CompileWarning(string msg = null, int? lineNumber = null, int? startIndex = null, int? length = null) : base(true, msg, lineNumber, startIndex, length) { }
    }
}